package com.ruoyi.web.controller.face.httpServer;

import com.google.gson.Gson;
import com.ruoyi.tongban.domain.face.ReturnUploadFaceData;
import com.ruoyi.tongban.domain.face.UploadFaceData;
import com.ruoyi.tongban.service.IFaceSignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description
 * @Author caiyanshan
 * @Date 2021/4/13 13:41
 * @Param
 * @Return
 */
@RestController
@RequestMapping("/api/v1")
public class FaceHttpApi {
  
  @Autowired
  private IFaceSignService faceSignService;
  
  @PostMapping("record/face")
  public String uploadData(@RequestBody UploadFaceData upload){
    
    for(UploadFaceData.user user : upload.getLogs()){
      user.setSn(upload.getSn());
      faceSignService.handleFaceSign(user);
    }

    Gson gson = new Gson();
    ReturnUploadFaceData returnUploadFaceData = new ReturnUploadFaceData();
    returnUploadFaceData.setContent("");
    returnUploadFaceData.setMsg("");
    returnUploadFaceData.setResult(0);
    return gson.toJson(returnUploadFaceData);
  }
}
